<template>
  <view class="background">
    <view class="icon_background">
      <text @click="btn_fanhui" class="icon_sym icon-zuojiantou"></text>
      <text @click="btn_baocun" class="icon_sym icon-baocun"></text>
    </view>
    <view class="hr"></view>
    <A_inputs ref="json_input" placeholder="json文本"></A_inputs>
  </view>
</template>

<script setup>
import '../../static/icon.css'
import { ref } from 'vue'
import g from '@/common/global'

const json_input = ref(null)
// const app = getApp()
function btn_fanhui() {
  console.log('点击了返回')

  uni.redirectTo({
    url: '/pages/index/index',
  })
}
function btn_baocun() {
  console.log('点击了保存')
  let r = json_input.value.get_input_value().trim()
  if (r.startsWith('var rule')) {
    g.rule = eval(r + ';rule')
  } else if (r.startsWith('{')) {
    g.rule = eval('var rule =' + r + ';rule')
  }

  console.log(g.rule)
  try {
  } catch (e) {
    console.log(e)
    console.log('代码运行错误,请检查!!!')
    return
  }
  // console.log(a)
}
</script>

<style>
.background {
  width: 100%;
  height: 93vh;
  background-color: #eee;
}
.hr {
  height: 1px; /* 分割线高度 */
  background-color: #f0a682; /* 分割线颜色 */
  margin: 10px 0; /* 上下间距 */
}
.icon_background {
  display: flex;
  justify-content: space-between;
  /* background-color: red; */
  padding-top: 20px;
  margin-right: 20px;
}
.icon_sym {
  display: inline-block;
  width: 30px;
  height: 30px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100%;
  margin-left: 20px;
  /* padding: 40px; */
}
text:active {
  background-color: #ddd;
}
</style>
